#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcebuffer.h>
#include <gtksourceview/gtksourcelanguage.h>
#include <gtksourceview/gtksourcelanguagemanager.h>

#define POINT '.'
#define DEFAULT_FILE_PREFIX "Unsaved Document"


int default_file_sufix_init = 1; //
//GtkSourceBuffer *buffer;
//gchar *filename;
//GtkWidget *view;
GtkWidget *window;

typedef enum _status {
        SUCCESS,FAIL
} STATUS;

typedef struct _notebook_page {
    char *filename;
    int default_or_new_flag; //是否为默认文件名标志位,0|1
    GtkWidget *label; //关联文件标签
    GtkWidget *view; //关联文件视图
    GtkSourceBuffer *buffer; //关联文件缓冲区
    GtkWidget *statusbar;
} notebook_page;

char *get_default_filename();

void create_new_file(GtkWidget *widget, gpointer notebook);

void deal_switch_page(GtkNotebook *notebook, gpointer page, guint page_num, gpointer data);

void set_buffer_language(const gchar * lang, gpointer page);

STATUS _save_file(FILE *pFile, gchar *text, gpointer label);

void update_line_color(notebook_page *page);

char * get_file_suffix(const gchar* filename);

gchar* gtk_show_file_save(GtkWidget* parent_window, gchar *text, GtkWidget **dialog, gpointer page);

void set_font(GtkWidget *widget, gchar *fontname);

void select_font(GtkWidget *widget, gpointer page);

void select_color(GtkWidget *widget, gpointer page);

void show_about(GtkWidget *widget, gpointer data);

void update_statusbar(GtkSourceBuffer *buffer, GtkStatusbar *statusbar);

STATUS save_file(GtkWidget *widget, gpointer page);

gint open_file(GtkWidget *file, gpointer page);

void select_and_open_file(GtkWidget *widget,gpointer page);

void mark_set_callback(GtkSourceBuffer *buffer, const GtkTextIter \
        *new_location, GtkTextMark *mark, gpointer page);

void init_text_view(notebook_page *page);
